/*
 * @Title HelloStruts2Action.java
 * @Description
 * commons-fileupload-x.y.z.jar
 * commons-io-x.y.z.jar
 * commons-lang-x.y.jar
 * commons-logging-x.y.z.jar
 * commons-logging-api-x.y.jar
 * freemarker-x.y.z.jar
 * javassist-.xy.z.GA
 * ognl-x.y.z.jar
 * struts2-core-x.y.z.jar
 * xwork-core.x.y.z.jar
 * @Copyright Copyright(c) 2018
 * @Company com.lizhen
 * @author lizhen
 * @version 0.0.1
 */
package com.lizhen.struts2.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lizhen
 */
public class HelloStruts2Action extends ActionSupport {

    private static final long serialVersionUID = 1L;
    private String name;

    /**
     * @author lizhen
     */
    public HelloStruts2Action() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String execute() throws Exception {
        if ("lizhen".equals(name)) {
            ValueStack stack = ActionContext.getContext().getValueStack();
            Map<String, Object> context = new HashMap<>();
            context.put("key1", new String("This is key1"));
            context.put("key2", new String("This is key2"));
            stack.push(context);

            System.out.println("Size of the valueStack: " + stack.size());

            return SUCCESS;
        } else {
            return ERROR;
        }
    }

}